//
//  CMDBSearchCategoryBtn.swift
//  CMDB
//
//  Created by 曹桂祥 on 17/4/27.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBSearchCategoryBtn: UIButton {
    
    convenience init(titele:String , textColor : UIColor,selectedTextColor : UIColor, image: String ,selectedImage : String , titleSizeFont : UIFont)
    {
        
        self.init()
        
        setTitle(titele, forState: .Normal)
        
        titleLabel?.font = titleSizeFont
        
        setTitleColor(textColor, forState: .Normal)
        
        setTitleColor(selectedTextColor, forState: .Selected)
        
        setImage(UIImage(named: image), forState: .Normal)
        
        setImage(UIImage(named: selectedImage), forState: .Selected)
        
    }
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        let rect = self.bounds
        
        imageView?.frame = CGRect(x: 0, y: 0, width: rect.width, height: rect.width)
        
        titleLabel?.frame = CGRect(x: 0, y: CGRectGetMaxY(self.imageView!.frame) + 5, width: imageView!.width, height: 25)

        
    }

}


